Skip to content

bpo-35845: Add order={'C', 'F', 'A'} parameter to memoryview.tobytes().#11730

Merged
skrah merged 3 commits intopython:masterfrom
skrah:tobytes
Feb 2, 2019
Merged

bpo-35845: Add order={'C', 'F', 'A'} parameter to memoryview.tobytes().#11730
skrah merged 3 commits intopython:masterfrom
skrah:tobytes

Conversation

@skrah
Copy link
Copy Markdown
Contributor

@skrah skrah commented Feb 2, 2019

Comment thread Doc/library/stdtypes.rst
and the logical array structure.

.. method:: tobytes()
.. method:: tobytes(order=None)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you write it as order='C'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that common practice? I'd assume that order='C' means that a function raises a TypeError with a None argument. I supported None because NumPy does, too.

OTOH NumPy also documents the function with order='C', but I assumed that was an oversight or a historical quirk.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize that passing None explicitly was supported.

Comment thread Doc/library/stdtypes.rst Outdated

*Order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data
of the original array is converted to C or Fortran order. 'A' returns
the data in the existing order. The default order is 'C'.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a versionchanged tag for the new argument.

Comment thread Doc/library/stdtypes.rst Outdated

*Order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data
of the original array is converted to C or Fortran order. 'A' returns
the data in the existing order. The default order is 'C'.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than "existing order", I would say "physical order" (or more precisely, "'F' if the buffer is Fortran-contiguous, 'C' otherwise"?).

Copy link
Copy Markdown
Contributor Author

@skrah skrah Feb 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's use the more precise version. 'A' does convert non-contiguous buffers to 'C', so it should be mentioned.

@bedevere-bot
Copy link
Copy Markdown

@skrah: Please replace # with GH- in the commit message next time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants